class Solution:
    def subsets(self, nums):
        t = []
        ans = []

        def dfs(cur):
            if cur == len(nums):
                print(f"加入子集: {t.copy()}")
                ans.append(t.copy())
                return
            # 选择当前元素
            t.append(nums[cur])
            print(f"选择 {nums[cur]}, t={t}")
            dfs(cur + 1)
            # 回溯：不选当前元素
            t.pop()
            print(f"撤销选择 {nums[cur]}, t={t}")
            dfs(cur + 1)

        dfs(0)
        return ans


# 测试
solution = Solution()
print("\n最终结果:", solution.subsets([1, 2]))